package com.example.springmvc_study.controller;

import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;

/**
 * @ClassName RespAnyController
 * @Description TODO
 * @Author H.
 * @Date 2023/4/24 20:59
 * @Version 1.0
 */

@RestController
public class RespAnyController {

    @RequestMapping("/any")
    public ResponseEntity any() throws IOException {
        Path path = new File("C:\\Users\\15047\\Pictures\\Camera Roll\\4.jpg").toPath();
        byte[] bytes = Files.readAllBytes(path);
        return ResponseEntity.ok().header("content-type","application/x-jpg").body(bytes);
    }
}
